<template>
  <div class="count2">
    <button @click="add(num)">累加{{num}}</button>
    <h1>count: {{count}}</h1>
  </div>
</template>

<script>
export default {
  name: "Count2",

  props:["num"],

  data(){
    return{
      count: 0
    }
  },

  methods:{
    add(num){
        this.count += num
    }
  }
};
</script>

<style>
.count2 {
  background-color: hotpink;
  height: 300px;
}
</style>